
MAKEOVERRIDES=

-include config

all:

clean:
	$(if $(source),rm -rf $(source))
	$(if $(srctree),rm -rf $(srctree))
	$(if $(build),rm -rf $(build))
	rm -f config
	rm -f build
	rm -rf $(DEF_TEMP)

$(source):$(download)
	rm -rf $@
	mkdir -p $(DEF_TEMP)
	cd $(DEF_TEMP);tar axf $< $(srctree)
	mv $(DEF_TEMP)/$(srctree) $@
	rm -rf $(DEF_TEMP)
	$(foreach i,$(patch),patch -ftd$@ -p1< $(DIR_ORIG)/$(DEF_PATCH)/$i $_)
	touch -m $@

build:pre-build normal-build post-build
	touch -m $@

pre-build:$(source)

normal-build:pre-build

post-build:normal-build normal-build

pre%build:
ifeq '$(build)' ''
	cd $<;$(cdefs) ./configure $(cflags)
else
	rm -rf $(build)
	mkdir -p $(build)
	cd $(build);$(cdefs) ../$</configure $(cflags)
endif

normal%build:
	$(MAKE) -C $(if $(build),$(build),$(source)) $(mflags)

post%build:
	$(MAKE) -C $(if $(build),$(build),$(source)) $(iflags)

install:pre-install normal-install post-install

#pre-install:

normal-install:pre-install

post-install:normal-install pre-install

install-strip:
	@echo $(name)%$@

pre%install:
	@echo $(name)%$@

normal%install:
	@echo $(name)%$@

post%install:
	@echo $(name)%$@

dist:

check:

download:$(download)
#	echo %$@

%.tgz %.tar.gz %.tar.bz2 %.tar %.diff.gz %.cvd %.gz %.tar.xz %.zip:
	rm -f $@.tmp 
ifeq '$(DL_SERV)' 'svn'
	rm -rf $(subst $(addprefix .,$(DL_SUFFIX)),,$@)
	rm -f $(DEF_TEMP)-$@
	svn co $(DL_SERV)://$(DL_HOST)$(addprefix :,$(DL_PORT))/$(DL_PATH) $(subst $(addprefix .,$(DL_SUFFIX)),,$@)
	find $(subst $(addprefix .,$(DL_SUFFIX)),,$@) -name '.svn' -exec rm -rf {} \; >/dev/null 2>&1 ;exit 0
	tar acf $(DEF_TEMP)-$@ $(subst $(addprefix .,$(DL_SUFFIX)),,$@)
	rm -rf $(subst $(addprefix .,$(DL_SUFFIX)),,$@)
	mv $(DEF_TEMP)-$@ $@.$(DEF_TEMP)
else
	LANG= wget $(DL_SERV)://$(DL_HOST)$(addprefix :,$(DL_PORT))/$(DL_PATH)/$@ -O$@.$(DEF_TEMP)
endif
	find -empty -type f -name $@.$(DEF_TEMP)
	mkdir -p $(DIR_DOWNLOAD)
	mv $@.$(DEF_TEMP) $(DIR_DOWNLOAD)/$(@F)
	touch -m $(DIR_DOWNLOAD)/$(@F)

ifeq '$(wildcard config)' ''
config:
	echo pid=$(PID) >$@
	$(foreach i,$(DEF_MICRO),$(if $($i),echo $i='$($i)' >>$@ $_))
else
ifneq '$(PID)' '$(pid)'
config:force
	rm -f $@
endif
endif
force:;
